package com.acwing.partition45;

import java.io.*;

/**
 * @author rkc
 * @date 2022/8/16 9:08
 */
public class AC4405统计子矩阵 {

    private static final int N = 510;
    private static int[][] s = new int[N][N];
    private static int n, m, k;

    private static StreamTokenizer tokenizer = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    private static PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        n = nextInt(); m = nextInt(); k = nextInt();
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                s[i][j] = nextInt();
                s[i][j] += s[i - 1][j];
            }
        }
        long ans = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = i; j <= n; j++) {
                for (int l = 1, r = 1, sum = 0; r <= m; r++) {
                    sum += s[j][r] - s[i - 1][r];
                    while (sum > k) {
                        sum -= s[j][l] - s[i - 1][l];
                        l++;
                    }
                    ans += r - l + 1;
                }
            }
        }
        writer.println(ans);
        writer.flush();
    }

    private static int nextInt() throws IOException {
        tokenizer.nextToken();
        return (int) tokenizer.nval;
    }
}
